<template>
  <div class="record">
    <!-- Form -->

    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="个人档案" name="first">
        <div class="aaaa">
          <el-descriptions
            class="margin-top"
            title="基本信息"
            :column="2"
            border
          >
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>姓名
              </template>
              <el-input
                v-model="form.name"
                placeholder="请输入内容"
                @blur="nameBlur"
              ></el-input>
            </el-descriptions-item>

            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                性别
              </template>
              <el-select v-model="form.sex" clearable placeholder="请选择">
                <el-option :value="0" label="女" />
                <el-option :value="1" label="男" />
              </el-select>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                身份证
              </template>
              <el-input
                v-model="form.cardId"
                placeholder="请输入内容"
                @blur="cardIdBlur"
                maxlength="18"
              ></el-input>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                户籍地址
              </template>
              <el-input v-model="form.address" placeholder="请输入内容">
                {{ form.address }}</el-input
              >
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                现居住地
              </template>
              <el-input v-model="form.residence" placeholder="请输入内容"
                >{{ form.residence }}
              </el-input>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                手机号
              </template>
              <el-input
                v-model="form.number"
                placeholder="请输入内容"
                @blur="numberBlur"
                maxlength="11"
              ></el-input>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                邮箱地址
              </template>
              <el-input
                v-model="form.email"
                placeholder="请输入内容"
                @blur="emailBlur"
              ></el-input>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                紧急联系人
              </template>
              <el-input
                v-model="form.nameIs"
                placeholder="请输入内容"
              ></el-input>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                紧急联系电话
              </template>
              <el-input
                v-model="form.numberIs"
                placeholder="请输入内容"
                @blur="numberIsBlur"
                maxlength="11"
              ></el-input>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                工资卡
              </template>
              <el-input v-model="form.playCard" placeholder="请输入内容">
                {{ form.playCard }}</el-input
              >
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                支付宝账号
              </template>
              <el-input v-model="form.zhifubao" placeholder="请输入内容">
                {{ form.zhifubao }}</el-input
              >
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label"> </template>
            </el-descriptions-item>
          </el-descriptions>
          <br />
          <br />

          <el-descriptions
            class="margin-top"
            title="工作信息"
            :column="2"
            border
          >
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                工号
              </template>
              {{ form.id }}
            </el-descriptions-item>

            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                入职日期
              </template>
              <el-date-picker
                v-model="form.gmtBoard"
                type="datetime"
                placeholder="选择日期时间"
                value-format="yyyy-MM-dd HH:mm:ss"
                format="yyyy-MM-dd HH:mm:ss"
                :picker-options="pickerOptions0"
              >
              </el-date-picker>
            </el-descriptions-item>

            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                转正日期
              </template>
              <el-date-picker
                v-model="form.gmtPositive"
                type="datetime"
                placeholder="选择日期时间"
                value-format="yyyy-MM-dd HH:mm:ss"
                format="yyyy-MM-dd HH:mm:ss"
                :picker-options="pickerOptions0"
              >
              </el-date-picker>
            </el-descriptions-item>

            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                组织
              </template>
              {{ form.organization }}
            </el-descriptions-item>

            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                部门
              </template>
              <el-select
                v-model="form.sectorid"
                placeholder="请选择"
                @change="myGetPositionInfo"
              >
                <el-option
                  v-for="sector in sectorList"
                  :key="sector.sectorid"
                  :label="sector.sector"
                  :value="sector.sectorid"
                />
              </el-select>
            </el-descriptions-item>

            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                职位
              </template>
              <el-select v-model="form.postid" placeholder="请选择">
                <el-option
                  v-for="post in postList2"
                  :key="post.postid"
                  :label="post.post"
                  :value="post.postid"
                />
              </el-select>
            </el-descriptions-item>

            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                职级
              </template>

              <el-select v-model="form.gradesid" placeholder="请选择">
                <el-option
                  v-for="grades in gradesList"
                  :key="grades.gradesid"
                  :label="grades.grades"
                  :value="grades.gradesid"
                />
              </el-select>
            </el-descriptions-item>

            <el-descriptions-item>
              <template slot="label"> </template>
            </el-descriptions-item>
          </el-descriptions>
          <br /><br /><br />
          <div style="text-align: right">
            <el-button
              @click="remove(form.id)"
              style="float: right; margin: 0px 30px"
              plain
              >删除</el-button
            >

            <el-button
              style="float: right; margin: 0px 20px"
              plain
              slot="reference"
              type="primary"
              @click="dialogFormVisible = true"
              >离职</el-button
            >
            <el-button
              type="primary"
              @click="updateHr1"
              style="float: right; margin: 0px 30px"
              plain
              >确认修改</el-button
            >
          </div>
          <br /><br /><br />
          <el-dialog title="离职" :visible.sync="dialogFormVisible">
            <el-form :model="form" :inline="true">
              <el-form-item label="离职日期">
    
                <el-date-picker
                  v-model="form.gmtDeparture"
                  type="datetime"
                  placeholder="选择日期时间"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  format="yyyy-MM-dd HH:mm:ss"
                  :picker-options="pickerOptions0"
                  ><i slot="suffix" class="el-input__icon el-icon-date"></i>
                </el-date-picker>
              </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
              <el-button type="primary" @click="updateHr">确定</el-button>
            </div>
          </el-dialog>
        </div>
      </el-tab-pane>
      <el-tab-pane label="绩效管理" name="second">
        <div id="example">
          <div v-show="isShow">
            <nobr
              >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i
                class="el-icon-user-solid"
              ></i
              >工作理念</nobr
            >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <el-button class="small" type="text" @click="showToggle"
              ><i class="el-icon-circle-plus-outline"></i>添加</el-button
            >
            <el-table :data="perForm1" border style="width: 100%">
              <el-table-column
                align="center"
                prop="yearIdea"
                label="年份"
                width="180"
              >
              </el-table-column>
              <el-table-column
                align="center"
                prop="quarter"
                :formatter="stateFormat"
                label="季度"
                width="180"
              >
              </el-table-column>
              <el-table-column
                align="center"
                prop="teamwork"
                label="团队协作"
                width="180"
              >
              </el-table-column>
              <el-table-column align="center" prop="dedicated" label="敬业">
              </el-table-column>
              <el-table-column align="center" prop="serve" label="服务意识">
              </el-table-column>
              <el-table-column align="center" prop="hug" label="拥抱变化">
              </el-table-column>
              <el-table-column align="center" prop="sumIdea" label="合计">
              </el-table-column>
              <el-table-column align="center" label="操作">
                <template slot-scope="scope">
                  <el-button type="text" @click="updatePerIdeaById(scope.row)"
                    >删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>

            <br /><br />
            <nobr
              >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i
                class="el-icon-user-solid"
              ></i
              >工作能力</nobr
            >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <el-button class="small" type="text" @click="showToggle1"
              ><i class="el-icon-circle-plus-outline"></i>添加</el-button
            >
            <el-table :data="perForm2" border style="width: 100%">
              <el-table-column
                align="center"
                prop="yearScarce"
                label="年份"
                width="180"
              >
              </el-table-column>
              <el-table-column
                align="center"
                prop="quarterScarce"
                :formatter="stateFormat1"
                label="季度"
                width="180"
              >
              </el-table-column>
              <el-table-column
                align="center"
                prop="code"
                label="代码同步"
                width="180"
              >
              </el-table-column>
              <el-table-column align="center" prop="ego" label="自我测试">
              </el-table-column>
              <el-table-column align="center" prop="task" label="任务执行">
              </el-table-column>
              <el-table-column align="center" prop="quality" label="代码质量">
              </el-table-column>
              <el-table-column align="center" prop="solve" label="解决问题">
              </el-table-column>
              <el-table-column align="center" prop="report" label="工作报告">
              </el-table-column>
              <el-table-column align="center" prop="sumBility" label="合计">
              </el-table-column>
              <el-table-column align="center" prop="name" label="操作">
                <template slot-scope="scope">
                  <el-button type="text" @click="deletePer(scope.row)"
                    >删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <div v-show="showRentPrise">
          <el-tabs v-model="activeName1" @tab-click="handleClick1">
            <el-tab-pane label="工作理念" name="first1"
              ><div>
                <br /><br />

                <el-form
                  :inline="true"
                  class="demo-form-inline"
                  label-width="100px"
                >
                  <el-form-item label="年限">
                    <el-date-picker
                      v-model="perForm.yearIdea"
                      type="year"
                      placeholder="选择年"
                      value-format="yyyy"
                      format="yyyy"
                    >
                    </el-date-picker>
                  </el-form-item>
                  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                  <el-form-item label="季度">
                    <el-select
                      v-model="perForm.quarter"
                      placeholder="请选择季度"
                    >
                      <el-option label="第一季度" value="1"></el-option>
                      <el-option label="第二季度" value="2"></el-option>
                      <el-option label="第三季度" value="3"></el-option>
                      <el-option label="第四季度" value="4"></el-option>
                    </el-select>
                  </el-form-item>
                </el-form>
              </div>
              <el-form ref="form" :model="perForm" label-width="100px">
                <el-form-item label="团队协作">
                  <el-input
                    v-model="perForm.teamwork"
                    style="width: 140px"
                    placeholder="得分"
                     maxlength="2"
                  ></el-input>
                </el-form-item>
                <el-form-item label="案例">
                  <el-input
                    placeholder="请输入"
                    type="textarea"
                    v-model="perForm.teamworkCase"
                    style="width: 800px"
                  ></el-input>
                </el-form-item>
                <el-form-item label="敬业">
                  <el-input
                    v-model="perForm.dedicated"
                    style="width: 140px"
                    placeholder="得分"
                    maxlength="2"
                  ></el-input>
                </el-form-item>
                <el-form-item label="案例">
                  <el-input
                    placeholder="请输入"
                    type="textarea"
                    v-model="perForm.dedicatedCase"
                    style="width: 800px"
                  ></el-input>
                </el-form-item>
                <el-form-item label="服务意识">
                  <el-input
                    v-model="perForm.serve"
                    style="width: 140px"
                    placeholder="得分"
                    maxlength="2"
                  ></el-input>
                </el-form-item>
                <el-form-item label="案例">
                  <el-input
                    placeholder="请输入"
                    type="textarea"
                    v-model="perForm.serveCase"
                    style="width: 800px"
                  ></el-input>
                </el-form-item>
                <el-form-item label="拥抱变化">
                  <el-input
                    v-model="perForm.hug"
                    style="width: 140px"
                    placeholder="得分"
                    maxlength="2"
                  ></el-input>
                </el-form-item>
                <el-form-item label="案例">
                  <el-input
                    placeholder="请输入"
                    type="textarea"
                    v-model="perForm.hugCase"
                    style="width: 800px"
                  ></el-input>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="addPerformance"
                    >保存</el-button
                  >
                  <el-button @click="eaitReturn">返回</el-button>
                </el-form-item>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="工作能力" name="first2">
              <el-form ref="form" :model="perForm" label-width="100px">
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                <el-form
                  :inline="true"
                  class="demo-form-inline"
                  label-width="100px"
                >
                  <el-form-item label="年限">
                    <el-date-picker
                      v-model="perForm.yearScarce"
                      type="year"
                      placeholder="选择年"
                      value-format="yyyy"
                      format="yyyy"
                    >
                    </el-date-picker>
                  </el-form-item>
                  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                  <el-form-item label="季度">
                    <el-select
                      v-model="perForm.quarterScarce"
                      placeholder="请选择季度"
                    >
                      <el-option label="第一季度" value="1"></el-option>
                      <el-option label="第二季度" value="2"></el-option>
                      <el-option label="第三季度" value="3"></el-option>
                      <el-option label="第四季度" value="4"></el-option>
                    </el-select>
                  </el-form-item>
                </el-form>
                <el-form-item label="代码同步">
                  <el-input
                    v-model="perForm.code"
                    style="width: 140px"
                    placeholder="得分"
                    maxlength="2"
                  ></el-input>
                </el-form-item>
                <el-form-item label="案例">
                  <el-input
                    placeholder="请输入"
                    type="textarea"
                    v-model="perForm.codeCase"
                    style="width: 800px"
                  ></el-input>
                </el-form-item>
                <el-form-item label="自我测试">
                  <el-input
                    v-model="perForm.ego"
                    style="width: 140px"
                    placeholder="得分"
                    maxlength="2"
                  ></el-input>
                </el-form-item>
                <el-form-item label="案例">
                  <el-input
                    placeholder="请输入"
                    type="textarea"
                    v-model="perForm.egoCase"
                    style="width: 800px"
                  ></el-input>
                </el-form-item>
                <el-form-item label="任务执行">
                  <el-input
                    v-model="perForm.task"
                    style="width: 140px"
                    placeholder="得分"
                    maxlength="2"
                  ></el-input>
                </el-form-item>
                <el-form-item label="案例">
                  <el-input
                    placeholder="请输入"
                    type="textarea"
                    v-model="perForm.taskCase"
                    style="width: 800px"
                  ></el-input>
                </el-form-item>
                <el-form-item label="代码质量">
                  <el-input
                    v-model="perForm.quality"
                    style="width: 140px"
                    placeholder="得分"
                    maxlength="2"
                  ></el-input>
                </el-form-item>
                <el-form-item label="案例">
                  <el-input
                    placeholder="请输入"
                    type="textarea"
                    v-model="perForm.qualityCase"
                    style="width: 800px"
                  ></el-input>
                </el-form-item>
                <el-form-item label="解决问题">
                  <el-input
                    v-model="perForm.solve"
                    style="width: 140px"
                    placeholder="得分"
                    maxlength="2"
                  ></el-input>
                </el-form-item>
                <el-form-item label="案例">
                  <el-input
                    placeholder="请输入"
                    type="textarea"
                    v-model="perForm.solveCase"
                    style="width: 800px"
                  ></el-input>
                </el-form-item>
                <el-form-item label="工作质量报告">
                  <el-input
                    v-model="perForm.report"
                    style="width: 140px"
                    placeholder="得分"
                    maxlength="2"
                  ></el-input>
                </el-form-item>
                <el-form-item label="案例">
                  <el-input
                    placeholder="请输入"
                    type="textarea"
                    v-model="perForm.reportCase"
                    style="width: 800px"
                  ></el-input>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="addPerformanceAbility"
                    >保存</el-button
                  >
                  <el-button @click="eaitReturn">返回</el-button>
                </el-form-item>
              </el-form></el-tab-pane
            >
          </el-tabs>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import performanceApi from "@/api/hr/performance";
import profilesApi from "@/api/hr/profiles";
import gradesApi from "@/api/hr/grades";
import sectorApi from "@/api/hr/sector";
import positionApi from "@/api/hr/position";
import Link from "../layout/components/Sidebar/Link.vue";

export default {
  components: { Link },
  data() {
    return {
      showRentPrise: false,
      isShow: true,
      postList: [],
      postList2: [],
      sectorList: [],
      gradesList: [],
      pickerOptions0: {
        disabledDate(time) {
          return time.getTime() >= Date.now() - 8.64e7;
        },
      },
      perForm1: [],
      perForm2: [],
      perForm: {
        id: "",
        profilesid: this.$route.params.id,
        code: "",
        codeCase: "",
        ego: "",
        egoCase: "",
        task: "",
        taskCase: "",
        quality: "",
        qualityCase: "",
        solve: "",
        solveCase: "",
        report: "",
        reportCase: "",
        year: "",
        quarter: "",
        teamwork: "",
        teamworkCase: "",
        dedicated: "",
        dedicatedCase: "",
        serve: "",
        serveCase: "",
        hug: "",
        hugCase: "",
        yearIdea: "",
        quarter: "",
        quarterScarce: "",
        yearScarce: "",
      },
      form: {
        name: "",
        sex: "",
        cardId: "",
        address: "",
        residence: "",
        number: "",
        email: "",
        nameIs: "",
        numberIs: "",
        playCard: "",
        zhifubao: "",
        //工作信息
        id: "",
        gmtBoard: "",
        gmtPositive: "",
        organization: "",
        post: "",
        postid: "",
        grades: "",
        sector: "",
        gmtDeparture: "",
        gradesid: "",
      },
      dialogFormVisible: false,
      activeName: "first",
      activeName1: "first1",
    };
  },
  created() {
    const id = this.$route.params.id;
    // let id=
    this.getByid();
    this.getGralist();
    this.getSeclist();
    //this.getByProId(id);
    this.getPerBilityById(id);
    this.getPerIdeaById(id);
  },

  methods: {
    //工作理念
    updatePerIdeaById(row) {
      this.$confirm("此操作将删除该条绩效, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let id = row.id;
          performanceApi.updatePerIdeaById(id).then((res) => {
            if (res.success == true) {
              this.$message({
                type: "success",
                message: "删除成功!",
              });
              //this.getByProId(id);
               const id = this.$route.params.id;
              this.getPerBilityById(id);
              this.getPerIdeaById(id);
            } else {
              alert("删除失败");
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },

    // 工作能力
    deletePer(row) {
      this.$confirm("此操作将删除该条绩效, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let id = row.id;
          performanceApi.updatePerformance(id).then((res) => {
            if (res.success == true) {
              this.$message({
                type: "success",
                message: "删除成功!",
              });
              // this.getByProId(id);
               const id = this.$route.params.id;
              this.getPerBilityById(id);
              this.getPerIdeaById(id);
            } else {
              alert("删除失败");
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //工作能力
    addPerformanceAbility() {
      if (this.perForm.yearScarce == null || this.perForm.yearScarce == "") {
        alert("年份不能为空,请重新输入");
        return;
      } else if (
        this.perForm.quarterScarce == null ||
        this.perForm.quarterScarce == ""
      ) {
        alert("季度不可以为空");
        return;
      }else if (this.perForm.code==null||this.perForm.code=="") {
        alert("代码同步得分不能为空")
        return;
      }else if (this.perForm.ego==null||this.perForm.ego=="") {
        alert("自我测试得分不能为空")
        return;
      }else if (this.perForm.task==null||this.perForm.task=="") {
        alert("任务执行得分不能为空")
        return;
      }else if (this.perForm.quality==null||this.perForm.quality=="") {
        alert("代码质量得分不能为空")
        return;
      }else if (this.perForm.solve==null||this.perForm.solve=="") {
        alert("解决问题得分不能为空")
        return;
      }else if (this.perForm.report==null||this.perForm.report=="") {
        alert("共作报告质量得分不能为空")
        return;
      }
      performanceApi
        .addPerformanceAbility(
          this.perForm.profilesid,
          this.perForm.yearScarce,
          this.perForm.quarterScarce
        )
        .then((response) => {
          if (response.data.flag == true) {
            this.$message({
              message: "已有该绩效，请重新选择",
              type: "warning",
            });
            return;
          }

          performanceApi.addPerformance(this.perForm).then((res) => {
            if (res.success == true) {
              this.$message({
                message: "恭喜你，添加成功",
                type: "success",
              });
              const id = this.$route.params.id;
              // this.getByProId(id);
              this.getPerBilityById(id);
              this.getPerIdeaById(id);
              this.isShow = !this.isShow;
              this.showRentPrise = false;
              this.perForm = {
                id: "",
                profilesid: this.$route.params.id,
                code: "",
                codeCase: "",
                ego: "",
                egoCase: "",
                task: "",
                taskCase: "",
                quality: "",
                qualityCase: "",
                solve: "",
                solveCase: "",
                report: "",
                reportCase: "",
                year: "",
                quarter: "",
                teamwork: "",
                teamworkCase: "",
                dedicated: "",
                dedicatedCase: "",
                serve: "",
                serveCase: "",
                hug: "",
                hugCase: "",
                yearIdea: "",
                quarter: "",
                quarterScarce: "",
                yearScarce: "",
              };
            } else {
              this.$message.error("添加失败");
            }
          });
        });
    },

    //工作理念
    addPerformance() {
      if (this.perForm.yearIdea == null || this.perForm.yearIdea == "") {
        alert("年份不能为空,请重新输入");
        return;
      } else if (this.perForm.quarter == null || this.perForm.quarter == "") {
        alert("季度不可以为空");
        return;
      }else if (this.perForm.teamwork == null || this.perForm.teamwork == "") {
        alert("团队协作得分不可以为空");
        return;
      }else if (this.perForm.dedicated == null || this.perForm.dedicated == "") {
        alert("敬业得分不可以为空");
        return;
      }else if (this.perForm.serve == null || this.perForm.serve == "") {
        alert("服务意识得分不可以为空");
        return;
      }else if (this.perForm.hug == null || this.perForm.hug == "") {
        alert("拥抱变化得分不可以为空");
        return;
      }
      performanceApi
        .getPerformanceOne(
          this.perForm.profilesid,
          this.perForm.yearIdea,
          this.perForm.quarter
        )
        .then((response) => {
          if (response.data.flag == true) {
            this.$message({
              message: "已有该绩效，请重新选择",
              type: "warning",
            });
            return;
          }

          performanceApi.addPerformance(this.perForm).then((res) => {
            if (res.success == true) {
              this.$message({
                message: "恭喜你，添加成功",
                type: "success",
              });
              const id = this.$route.params.id;
              // this.getByProId(id);
              this.getPerBilityById(id);
              this.getPerIdeaById(id);
              this.isShow = !this.isShow;
              this.showRentPrise = false;
              this.perForm = {
                id: "",
                profilesid: this.$route.params.id,
                code: "",
                codeCase: "",
                ego: "",
                egoCase: "",
                task: "",
                taskCase: "",
                quality: "",
                qualityCase: "",
                solve: "",
                solveCase: "",
                report: "",
                reportCase: "",
                year: "",
                quarter: "",
                teamwork: "",
                teamworkCase: "",
                dedicated: "",
                dedicatedCase: "",
                serve: "",
                serveCase: "",
                hug: "",
                hugCase: "",
                yearIdea: "",
                quarter: "",
                quarterScarce: "",
                yearScarce: "",
              };
            } else {
              this.$message.error("添加失败");
            }
          });
        });
    },

    // getByProId(id) {
    //   performanceApi.getByProId(id).then((response) => {
    //     this.perForm1 = response.data.PerformanceList;
    //   });
    // },
    //工作理念
    getPerIdeaById(id) {
      performanceApi.getPerIdeaById(id).then((response) => {
      
           this.perForm1 = response.data.PerformanceIdeaList;
     
        
      });
    },
//工作能力
    getPerBilityById(id) {
      performanceApi.getPerBilityById(id).then((response) => {
    
      
            this.perForm2 = response.data.PerformanceBilityList;  
      
      });
    },

    //返回
    eaitReturn() {
      const id = this.$route.params.id;
      this.isShow = true;
      this.showRentPrise = false;
      this.getPerBilityById(id);
      this.getPerIdeaById(id);
      //this.getByProId(id);
    },
    //隐藏div
    showToggle: function () {
      this.isShow = !this.isShow;
      this.showRentPrise = true;
      this.activeName1 = "first1";
    },
    showToggle1: function () {
      this.isShow = !this.isShow;
      this.showRentPrise = true;
      this.activeName1 = "first2";
    },

    stateFormat1(row, column) {
      if (row.quarterScarce === 1) {
        return "第一季度";
      }
      if (row.quarterScarce === 2) {
        return "第二季度";
      }
      if (row.quarterScarce === 3) {
        return "第三季度";
      }
      if (row.quarterScarce === 4) {
        return "第四季度";
      } else {
        return "";
      }
    },
    stateFormat(row, column) {
      if (row.quarter === 1) {
        return "第一季度";
      }
      if (row.quarter === 2) {
        return "第二季度";
      }
      if (row.quarter === 3) {
        return "第三季度";
      }
      if (row.quarter === 4) {
        return "第四季度";
      } else {
        return "";
      }
    },
    removeBatch() {},
    //获取职位列表
    getPoslist() {
      positionApi.getPoslist().then((response) => {
        this.postList = response.data.positionList;
      });
    },
    myGetPositionInfo(value) {
      positionApi.getPositionInfo(value).then((response) => {
      
        this.postList2 = response.data.items;
      
        if (this.postList2.length == 0) {
          this.form.postid = "";
        } else {
          this.form.postid = this.postList2[0].postid;
        }
      });
    },

    //根据部门id获取职位
    getPost(id) {
      positionApi.getPositionInfo(id).then((response) => {
        this.postList2 = response.data.items;
      });
    },

    //获取部门列表
    getSeclist() {
      sectorApi.getSeclist().then((response) => {

        this.sectorList = response.data.sectorList;
       
      });
    },
    //职级类型
    getGralist() {
      gradesApi.getGralist().then((response) => {
        this.gradesList = response.data.item;
      });
    },

    //修改档案
    numberIsBlur() {
      var regNumberIs = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
      if (this.form.numberIs == "") {
        alert("紧急联系电话不可以为空");
        return;
      } else if (!regNumberIs.test(this.form.numberIs)) {
        alert("紧急联系电话格式不正确");
        return;
      }
    },
    emailBlur() {
      var regEmail =
        /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
      if (this.form.email == "") {
        alert("邮箱不能为空");
      } else if (!regEmail.test(this.form.email)) {
        alert("邮箱格式不正确");
      }
    },
    numberBlur() {
      var reg = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
      if (this.form.number == "") {
        alert("手机号不可以为空");
        return;
      } else if (!reg.test(this.form.number)) {
        alert("手机号格式不正确");
        return;
      }
    },
    cardIdBlur() {
      var regCardId =
        /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/;
      if (this.form.cardId == "") {
        alert("身份证不能为空");
        return;
      } else if (!regCardId.test(this.form.cardId)) {
        alert("身份证各式不正确");
        return;
      }
    },
    nameBlur() {
      if (this.form.name == "") {
        alert("姓名不能为空");
        return;
      }
    },
    updateHr1() {
      var regCardId =
        /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/;
      var reg = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
      var regEmail =
        /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
      var regNumberIs = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
      if (this.form.numberIs == "" || this.form.numberIs == null) {
        alert("紧急联系人电话不可以为空");
        return;
      } else if (!regNumberIs.test(this.form.numberIs)) {
        alert("紧急联系人电话格式不正确");
        return;
      } else if (this.form.email == "" || this.form.email == null) {
        alert("邮箱不能为空");
      } else if (!regEmail.test(this.form.email)) {
        alert("邮箱格式不正确");
      } else if (this.form.number == "" || this.form.number == null) {
        alert("手机号不可以为空");
        return;
      } else if (!reg.test(this.form.number)) {
        alert("手机号格式不正确");
        return;
      } else if (this.form.cardId == "" || this.form.cardId == null) {
        alert("身份证不能为空");
        return;
      } else if (!regCardId.test(this.form.cardId)) {
        alert("身份证各式不正确");
        return;
      } else if (this.form.name == "" || this.form.name == null) {
        alert("姓名不能为空");
        return;
      } else if (this.form.gmtBoard >= this.form.gmtPositive) {
        alert("转正日期不能在入职日期之前");
        return;
      } else {
        profilesApi.updateHr(this.form).then((res) => {
          if (res.success) {
            this.$message({
              message: "修改成功",
              type: "success",
            });
            this.$router.push("/hr/profiles");
          } else {
            this.$message.error();
            ("修改成功");
          }
        });
      }
    },

    //离职
    updateHr() {
      // profilesApi.getGmtDeparture(this.form.gmtDeparture,this.form.id).then((response)=>{
      //  if (response.data.flag == true) {
      //       this.$message({
      //         message: "离职日期不能在入职日期之前",
      //         type: "warning",
      //       });
      //       return;
      //     }
     
      profilesApi.updateHr(this.form).then((res) => {
        if (this.form.gmtDeparture == null || this.form.gmtDeparture == "") {
          alert("离职日期不能为空");
          return;
        } else if (this.form.gmtBoard >= this.form.gmtDeparture) {
          alert("离职日期不能在入职日期之前");
          return;
        } else {
          if (res.success) {
            this.$message({
              message: "离职成功",
              type: "success",
            });
            this.form.gmtDeparture = {};
            this.$router.push("/hr/profiles");
          } else {
            this.$message.error("离职失败");
            
          }
        }
      });
       //})
    },

    remove(id) {
      this.$confirm("是否确认删除员工？", "删除", {
        cancelButtonText: "取消",
        confirmButtonText: "确认",
        type: "warning",
      })
        .then(() => {
          profilesApi.removeById(id).then((response) => {
            //成功

            if (response.success == true) {
              this.$message({
                message: "恭喜你，删除成功",
                type: "success",
              });

              this.$router.push("/hr/profiles");
            } else {
              alert("删除失败");
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消删除",
          });
        });
    },

    handleClick(tab, event) {
     
    },
    handleClick1(tab, event) {
    
    },
    getByid() {
      const id = this.$route.params.id;
      profilesApi.getByid(id).then((response) => {
        this.form = response.data.proRessultVoList[0];
        this.getPost(this.form.sectorid);
      });
    },
  },
};
</script>


<style scoped>
div.aaaa >>> input.el-input__inner {
  border-style: none;
  outline: none;
}
</style>